<template>
    <div class="ds-tbody">
      <el-dialog title="用户详情及健康档案" :model-value="show" @update:model-value="handleValueUpdate" @close="handleClose">
        <el-descriptions class="margin-top" title="用户基本信息" :column="2" :size="size" border>
          <el-descriptions-item :rowspan="2" :width="140" label="头像" align="center">
            <el-image style="width: 100px; height: 100px" :src="initFormData.avatarPath" />
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                用户姓名
              </div>
            </template>
            {{ initFormData.userName }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                用户昵称
              </div>
            </template>
            {{ initFormData.nickName }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                性别
              </div>
            </template>
            {{ initFormData.sex ? '男' : '女' }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                用户邮箱
              </div>
            </template>
            {{ initFormData.email }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                手机号
              </div>
            </template>
            {{ initFormData.phonenumber }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                出生年月
              </div>
            </template>
            {{ initFormData.birthDate }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                备注
              </div>
            </template>
            {{ initFormData.remark }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                隐私设置
              </div>
            </template>
            {{ initFormData.privacy ? '开启' : '关闭' }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                最新喜欢的服务项目
              </div>
            </template>
            {{ JsCustomerData.likeServiceName }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                最喜欢的技师
              </div>
            </template>
            {{ JsCustomerData.likeUserName }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                常用包厢号
              </div>
            </template>
            {{ initFormData.serveRoom }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                常用服务项目
              </div>
            </template>
            {{ JsCustomerData.servicePage }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                常用技师
              </div>
            </template>
            {{ JsCustomerData.jsUserName }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template #label>
              <div class="cell-item">
                常用茶水
              </div>
            </template>
            {{ JsCustomerData.serveTea }}
          </el-descriptions-item>
        </el-descriptions>
        <h3 style="margin-top: 20px;font-weight: bold;border-bottom: 1px solid #ddd;padding-bottom: 20px;">健康档案服务记录</h3>
        <div class="evaluate-list">
          <div class="evaluate-item" v-for="(item, i) in EvaluateCustomerIlist" :key="i">
            <div class="user-header flex-y-center">
              <div class="user-img flex-grow-0">
                <img :src="item.jsAvatarPath" alt="" />
              </div>
              <div class="user-name flex-grow-1">
                {{ item.jsNickName }}
              </div>
              <div class="user-time flex-grow-0">{{ item.createTime }}</div>
            </div>
            <div class="evaluate-cont">
              <div class="evaluate-text">
                {{ item.healthType }}足部套餐
              </div>
              <div class="TextArea">
                {{ item.serviceSummary }}
              </div>
              <div class="evaluate-imagelist" v-if="item.ossVoListPath && item.ossVoListPath.length">
                <div class="image-box" v-for="v in item.ossVoListPath">
                  <img :src="v.url" style="width: 91px; height: 91px;" alt="" />
                </div>
              </div>
              <div class="score-list">
                <div class="score-item">
                  <div class="score-name">敏感区域：</div>
                  <span>{{ item.sensitiveAreas }}</span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </el-dialog>
    </div>
  
  </template>
  
  <script setup name="appUserDs" lang="ts">
  import { ref, computed, defineProps, getCurrentInstance, onMounted, reactive } from 'vue'
  import { listAppUser, getAppUser, delAppUser, addAppUser, updateAppUser, getJsCustomer, getEvaluateCustomerId } from '@/api/system/appUser';
  import { AppUserVO, AppUserQuery, AppUserForm, UserExportVO } from '@/api/system/appUser/types';
  import {
    Iphone,
    Location,
    OfficeBuilding,
    Tickets,
    User,
  } from '@element-plus/icons-vue'
  import type { ComponentSize } from 'element-plus'
  const size = ref<ComponentSize>('default')
  const iconStyle = computed(() => {
    const marginMap = {
      large: '8px',
      default: '6px',
      small: '4px',
    }
    return {
      marginRight: marginMap[size.value] || marginMap.default,
    }
  })
  const blockMargin = computed(() => {
    const marginMap = {
      large: '32px',
      default: '28px',
      small: '24px',
    }
    return {
      marginTop: marginMap[size.value] || marginMap.default,
    }
  })
  
  const emit = defineEmits(['update:show'])
  const dialog = ref({
    visible: false,
    title: '用户详情'
  })
  
  const props = defineProps({
    show: {
      type: Boolean,
      default: false
    },
    Item: {
      type: Object,
      default: ''
    },
  
  })
  
  onMounted(() => {
    dialog.value.visible = props.visible
    initFormData.value = props.Item
    console.log(initFormData.value)
    getJsCustomerData()
    getEvaluateCustomerIlist()
  
  
  })
  const getJsCustomerData = async () => {
    const res = await getJsCustomer(initFormData.value.appUserId)
    JsCustomerData.value = res.data
    console.log(JsCustomerData.value)
  }
  const JsCustomerData = ref<UserExportVO>({})
  const EvaluateCustomerIlist = ref<any>([])
  const getEvaluateCustomerIlist = async () => {
    const res = await getEvaluateCustomerId(initFormData.value.appUserId)
    EvaluateCustomerIlist.value = res.data
    console.log(JsCustomerData.value)
  }
  
  
  
  const initFormData = ref<AppUserForm>({
    appUserId: undefined,
    openId: undefined,
    deptId: undefined,
    userName: undefined,
    nickName: undefined,
    userType: undefined,
    email: undefined,
    phonenumber: undefined,
    sex: undefined,
    avatar: undefined,
    password: undefined,
    birthDate: undefined,
    qualification: undefined,
    privacy: undefined,
    status: undefined,
    loginIp: undefined,
    loginDate: undefined,
    remark: undefined
  })
  const handleClose = () => {
    emit('update:show', false)
  }
  const handleValueUpdate = (val) => {
    emit('update:show', val)
  }
  </script>
  
  <style scoped lang="scss">
  .cell-item {
    width: 100px;
  }
  
  
  .evaluate-list {
    background: #fff;
  
    .evaluate-item {
      padding: 10px;
      border-bottom: 1px solid #f1f1f1;
      .user-img {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        overflow: hidden;
        margin-right: 22px;
        flex-grow: 0;
        img{
          width: 100%;
          height: 100%;
        }
      }
  
      .user-name {
        color: #333333;
      }
  
      .user-time {
        color: #666666;
      }
    }
  
    .evaluate-cont {
      margin: 20px 0px;
  
      .evaluate-text {
        color: #666666;
      }
    }
  
    .evaluate-imagelist {
      display: flex;
      flex-wrap: wrap;
  
      .image-box {
        width:90px;
        height: 90px;
        margin: 10px;
  
      }
    }
  
    .score-item {
      display: flex;
      align-items: center;
      color: #666;
    }
  }
  
  .user-header {
    display: flex;
    align-items: center;
  }
  
  .ds-tbody {
    max-height: 700px;
    overflow-y: scroll;
  }
  </style>